home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_shs_elevator.cog < prev    next >
Text File  |  1999-11-15  |  8KB  |  336 lines

  1. # Jones 3D Cog Script
  2. #
  3. # shs_Elevator.cog     Move the elevator.  
  4. #
  5. # [JWC] [PKM]
  6. #
  7. # (C) 1998 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ========================================================================================
  10.  
  11. symbols
  12.     message     startup
  13.     message     activated
  14.     message     entered
  15.     message        exited
  16.     message        aievent
  17.  
  18.  
  19.     keyframe    leverDown=gen_lever_pull.key        local
  20.     keyframe    indypull=in_pull_lever.key            local
  21.  
  22.     sound        leverPull=nub_lever_pull_c.wav        local
  23.     sound        leverBack=nub_lever_reset_c.wav        local
  24.     sound       liftmove=nub_elev_move_c.wav        local
  25.     sound       liftstop=nub_croc_stop_c.wav        local
  26.     sound        music=mus_gen_awesome3.wav            local
  27.  
  28.     thing        player            local 
  29.     thing        indy
  30.     thing        indy1            
  31.     thing        lift                  
  32.     thing        lever0
  33.     thing        rope0
  34.     thing        rope1
  35.     thing        rope2
  36.     thing        rope3
  37.  
  38.     thing        cam1
  39.     thing        cam2
  40.     thing        cam3
  41.     thing        cam4
  42.     thing        dummy1
  43.     thing        dummy2
  44.       thing        c1_t1
  45.     thing        walk_t1            
  46.     thing        walk_t2
  47.     thing        indy1_mk1
  48.  
  49.     int            liftpos=0        local # 0=down, 1=up
  50.     int            liftloop        local     
  51.     int         filter=0        local
  52.     int            bLeavingLift=0    local
  53.       int            musicPlayed=0    local
  54.  
  55.     cog            NoWorkTalkCog
  56.     
  57.     #SUB-ROUTINES
  58.     flex        ReturnControl    local
  59.     flex        Ride            local
  60.  
  61. end
  62.  
  63. # ========================================================================================
  64.  
  65. code
  66.  
  67. startup:
  68.  
  69.     AttachThingToThing(rope0, lift);
  70.     AttachThingToThing(rope1, lift);
  71.     AttachThingToThing(rope2, lift);
  72.     AttachThingToThing(rope3, lift);
  73.  
  74.     player = GetLocalPlayerThing();
  75.     return;
  76.  
  77. activated:
  78.     if (GetCurItem(player) != 0)
  79.         return; # prevents activating with chalk
  80.  
  81.     
  82.     # Handle potential "a" bug. lift upstairs, indy downstairs
  83.     if ((GetSenderRef() == lever0) && (filter == 0))
  84.     {
  85.         StartCutscene(0);
  86.         SetActorFlags(player, 0x200000);    # paralyze him
  87.         filter = 1;
  88.  
  89.         # Disable and hide player...
  90.         StopThing(player);                    # right now
  91.         PlayMode(player, 1, 0);                # get him into a nice stand
  92.         DeselectWeapon(player);                # stow any weapon or lighter
  93.         DeselectWeaponWait(player);
  94.         CopyPlayerHolsters(player, indy1);    # make sure our actor has matching props
  95.         Sleep(0.5);                            # give him some time to do his stuff
  96.  
  97.         # Switch actor indy for player...
  98.         TeleportThing(indy1, indy1_mk1);    # put actor in lever pull pos.
  99.         #SetActorHeadPYR(indy1,'0,0,0');        # reset actor head
  100.         
  101.         SetThingFlags(player, 0x80000);        # hide him
  102.         ClearThingFlags(indy1, 0x80000);    # reveal our actor
  103.  
  104.         # Prep camera & cut...
  105.         SetCameraLookInterp(2, 0);            # kill pan & tilt to lock on 2nd target
  106.         SetCameraPosInterp(2, 0);            # kill dolly mode too
  107.         SetCameraFocus(2, cam4);
  108.         SetCameraSecondaryFocus(2, indy1_mk1);
  109.         Sleep(0.01);
  110.         SetCurrentCamera(2);
  111.         SetCameraFOV(55, 0, 0.0);
  112.         
  113.         # Indy pulls lever
  114.         PlayKey(indy1, indyPull, 4, 0x12, 0);
  115.         PlayKey(lever0, leverDown, 4, 0x12, 0);
  116.         Sleep(1.2);
  117.         PlaySoundLocal(leverPull, 1.0, 0, 0x0000, 0);
  118.         Sleep(1.4);
  119.         PlaySoundLocal(leverBack, 1.0, 0, 0x0000, 0);
  120.         Sleep(0.3);
  121.         
  122.         if (liftpos == 0)  # can't activate when elevator already down
  123.         {
  124.             # Call NoWorkTalkCog
  125.             SendMessageEx(NoWorkTalkCog, user1, indy, 0, 0, 0);
  126.             global15 = 0; # per Randy
  127.             while (global15 == 0)
  128.             {
  129.                 Sleep(0.01); # wait for line to finish
  130.             }
  131.         }
  132.         else
  133.         {
  134.             # Prep camera & cut...
  135.             SetCameraLookInterp(2, 0);            # kill pan & tilt to lock on 2nd target
  136.             SetCameraPosInterp(2, 0);            # kill dolly mode too
  137.             SetCameraFocus(2, cam1);
  138.             SetCameraSecondaryFocus(2, c1_t1);
  139.             Sleep(0.01);
  140.             SetCurrentCamera(2);
  141.             
  142.             # indy looks at lift
  143.             TeleportThing(indy1, walk_t1);
  144.                        
  145.             # Lift on way
  146.             MoveToFrame(lift, 0, 5);
  147.             liftloop=PlaySoundLocal(liftmove, 1.0, 0, 0x1, 0); 
  148.             sleep(.75);
  149.             MoveToFrame(cam1, 0, 5); 
  150.             WaitForStop(lift);
  151.             StopSound(liftloop, 0.0);
  152.             PlaySoundLocal(liftstop, 1.0, 0, 0x0, 0);
  153.             liftpos = 0;
  154.         }
  155.         
  156.         # return control
  157.         SetCameraPosition(1, GetThingPos(dummy1));    # prep for camera to swing back
  158.         CopyOrientAndPos(indy1, player); # move player to actor's spot
  159.         SetThingFlags(indy1, 0x80000);
  160.         ClearThingFlags(player, 0x80000);
  161.         SetCameraLookInterp(2, 0); # kill pan & tilt mode
  162.         SetCameraPosInterp(2, 0); # kill dolly mode
  163.         Sleep(0.01);
  164.         ResetCameraFOV(0, 0.0);
  165.         SetCurrentCamera(1);
  166.         EndCutscene();
  167.         ClearActorFlags(player, 0x200000);
  168.         filter = 0;
  169.         
  170.     }
  171.     return;
  172.  
  173. entered:
  174.     if ((GetSenderRef() == lift) && (filter == 0))       
  175.     {
  176.         filter = 1;
  177.  
  178.         call Ride;
  179.  
  180.         if (liftpos == 0)
  181.         {
  182.             MoveToFrame(lift, 1, 5);
  183.             liftloop = PlaySoundLocal(liftmove, .9, 0, 0x1, 0);
  184.             sleep(.75);
  185.             MoveToFrame(cam1, 1, 5);
  186.             WaitForStop(lift);
  187.             StopSound(liftloop, 0.0);
  188.             PlaySoundLocal(liftstop, 1.0, 0, 0x0, 0);
  189.             liftpos = 1;
  190.             #return;
  191.         }
  192.         else
  193.         {
  194.             MoveToFrame(lift, 0, 5);
  195.             liftloop = PlaySoundLocal(liftmove, .9, 0, 0x1, 0);
  196.             sleep(.75);
  197.             MoveToFrame(cam1, 0, 5); 
  198.             WaitForStop(lift);
  199.             StopSound(liftloop, 0.0);
  200.             PlaySoundLocal(liftstop, 1.0, 0, 0x0, 0);
  201.             liftpos = 0;
  202.         }
  203.  
  204.         # Cut to show Indy walking out of lift
  205.         WaitForStop(cam1);
  206.         sleep(.5);
  207.  
  208.         # Prep camera & cut...
  209.         SetCameraLookInterp(2, 0);            # kill pan & tilt to lock on 2nd target
  210.         SetCameraPosInterp(2, 0);            # kill dolly mode too
  211.         Sleep(0.01);
  212.         if (liftpos == 0)
  213.         {
  214.             SetCameraFocus(2, cam2);        # downstairs
  215.         }
  216.         else
  217.         {
  218.             SetCameraFocus(2, cam3);        # upstairs
  219.         }
  220.  
  221.         SetCameraSecondaryFocus(2, indy);
  222.  
  223.         # Walk actor out of lift
  224.         bLeavingLift = 1;
  225.         if (liftpos == 0)
  226.         {
  227.             AISetMoveThing(indy, walk_t1, 1);
  228.         }
  229.         else
  230.         {
  231.             AISetMoveThing(indy, walk_t2, 1);
  232.         }
  233.     }
  234.     return;
  235.  
  236. exited:
  237.     if (GetSenderRef() != lift)
  238.         return;
  239.     filter = 0;
  240.     return;
  241.  
  242. aievent:
  243.     if  ((bLeavingLift) && (GetSenderRef() == indy) && (GetParam(0) == 0x800))
  244.     {
  245.         bLeavingLift = 0;
  246.         call ReturnControl;
  247.     }
  248.     return;
  249.  
  250. Ride:
  251.     MakeMeStop();                        # paralyze him
  252.     StartCutscene(0);
  253.  
  254.     # Disable and hide player...
  255.  
  256. //    DeselectWeaponWait(player);            # stow any weapon or lighter
  257.     CopyPlayerHolsters(player, indy);    # make sure our actor has matching props
  258.     CopyOrientAndPos(player, indy);     # move actor to player's spot
  259.  
  260.     Sleep(0.1);                            # give him some time to do his stuff
  261.  
  262.     # Switch actor indy for player...
  263.     SetThingFlags(player, 0x80000);        # hide him
  264.     AISetCutsceneMode(indy);
  265.     ClearThingFlags(indy, 0x80000);        # reveal our actor
  266.     TeleportThing(player, walk_t1);        # teleport player to safe place    prevents collision with geometry
  267.  
  268.     # Prep camera & cut...
  269.     SetCameraLookInterp(2, 0);            # kill pan & tilt to lock on 2nd target
  270.     SetCameraPosInterp(2, 0);            # kill dolly mode too
  271.     SetCameraFocus(2, cam1);
  272.     SetCameraSecondaryFocus(2, c1_t1);
  273.     SetCurrentCamera(2);
  274.     Sleep(0.01);
  275.  
  276.     AttachThingToThing(c1_t1, lift);        # glue camera on lift
  277. //    AttachThingToThing(cam1, lift); 
  278.  
  279.     # Play some music
  280.     if (musicPlayed == 0)
  281.     {
  282.         musicPlayed=1;
  283.         PlaySoundLocal(music, 1.0, 0, 0x0, 0);
  284.     }
  285.     
  286.     # Move actor to center of elevator
  287.     AISetMoveSpeed(indy, 1.0);
  288.     AISetMoveThing(indy, c1_t1, 1);
  289.  
  290.     # Spin Indy around
  291.     if (liftpos == 0)
  292.     {
  293.         AISetLookThing(indy, walk_t1);
  294.     }
  295.     else
  296.     {
  297.         AISetLookThing(indy, walk_t2);
  298.     }
  299.  
  300.     sleep(1);
  301.  
  302.     return;
  303.  
  304. ReturnControl:
  305.     # Return control and camera to player
  306.  
  307. //    SetThingMaxRotVel(indy, in_rotRate);# reset indy rotate velocity
  308. //    TeleportThing(indy, in_mk1);        # reset actor to original position
  309.     sleep(1);
  310.     CopyOrientAndPos(indy, player); # move player to actor's spot
  311.     SetActorHeadPYR(indy,'0,0,0');        # reset actor head
  312.     SetThingFlags(indy, 0x80000);
  313.     if (liftpos == 0)
  314.     {
  315.         SetCameraPosition(1, GetThingPos(dummy1));    # prep for camera to swing back
  316.     }
  317.     else
  318.     {
  319.         SetCameraPosition(1, GetThingPos(dummy2));    # prep for camera to swing back    
  320.     }
  321.     ClearThingFlags(player, 0x80000);
  322.     SetCameraLookInterp(2, 0); # kill pan & tilt mode
  323.     SetCameraPosInterp(2, 0); # kill dolly mode
  324.     Sleep(0.01);
  325.     SetCurrentCamera(1);
  326.     ResetCameraFOV(0, 0.0);
  327.     EndCutscene();
  328.     ClearActorFlags(player, 0x200000);
  329.  
  330.     return;
  331.  
  332. end
  333.  
  334.  
  335.  
  336.